/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package duplicateur;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Aurélie
 */
public class ThreadUpdateSupport extends Thread {
    private int nbSupports;
    private Duplicateur duplicateur;
    private ArrayList supports;
    InterfaceDuplicateur interfaceD;
    
    public ThreadUpdateSupport (InterfaceDuplicateur interfaceDuplicateur) {
        this.interfaceD = interfaceDuplicateur;
        this.duplicateur = this.interfaceD.getDuplicateur();
        this.supports = this.duplicateur.getAllSupport();
        this.nbSupports = this.supports.size();
    }
    
    public void run () {
        try {
            while (true) {
               Thread.sleep(3000);
                this.supports = this.duplicateur.getAllSupport();
                if (this.supports.size() != this.nbSupports) {
                    this.nbSupports = this.supports.size();
                    this.interfaceD.updateSupports();
                } 
            }            
        } catch (InterruptedException ex) {
            Logger.getLogger(ThreadUpdateSupport.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
